package cn.csxw.openchina.dagger2.presenter;

import javax.inject.Inject;

import cn.csxw.openchina.entity.bean.BlogBean;
import cn.csxw.openchina.entity.bean.OsChinaBean;
import cn.csxw.openchina.ui.activity.BlogDetailActivity;
import retrofit2.Call;

/**
 * Created by hp on 2017/1/17.
 */

public class BlogDetailActivityPresenter extends BasePresenter {
    BlogDetailActivity mBlogDetailActivity;

    @Inject
    public BlogDetailActivityPresenter(BlogDetailActivity blogDetailActivity) {
        mBlogDetailActivity = blogDetailActivity;
    }

    @Override
    protected void processData(OsChinaBean data) {
        if (data != null) {
            BlogBean blog = data.blog;
            mBlogDetailActivity.doNetWork(blog);
        }
    }

    @Override
    public void callNetWork(Object... params) {
        if (params.length != 1 || !(params[0] instanceof String)) {
            throw new IllegalArgumentException("参数是一个String类型的数据");
        }
        Call<OsChinaBean> blogDetailInfo = mOsChinaServer.getBlogDetailInfo((String) params[0]);
        blogDetailInfo.enqueue(mCallback);
    }
}
